* How does the flow of remittances affect the trade balance of the Middle East and North Africa?
*Mohammad Reza Farzanegan and Sherif Maher Hassan
*20 April 2019, Journal of Economic Policy Reform
*farzanegan@uni-marburg.de 

clear

use stata_remit.dta
xtset id time


xtreg tb remit inv y yf z aid rents fdi polity dcr inf scho , fe
estimates store fixed
xtreg tb remit inv y yf z aid rents fdi polity dcr inf scho , re
estimates store random
hausman fixed random


*fixed effects - Table 1 

xtreg tb remit inv y yf z , fe vce(cluster id)
est store a1

xtreg tb remitpercapita inv y yf z , fe vce(cluster id)
est store a2

xtreg tb remit inv y yf z aid rents fdi polity dcr inf scho , fe vce(cluster id)
est store a3

xi: xtreg tb remit inv y yf z aid rents fdi polity dcr inf scho i.time , fe vce(cluster id)
est store a4

xtreg tb remitpercapita inv y yf z aid rents fdi polity dcr inf scho , fe vce(cluster id)
est store a5

xtreg tb remit inv remitinv y yf z aid1 rents1 fdi polity dcr inf scho , fe vce(cluster id)
est store a6

xtreg tb remit remitsqu inv y yf z aid1 rents1 fdi polity dcr inf scho , fe
est store a7


xtreg tb remitpercapita inv remitpcinv y yf z aid rents fdi polity dcr inf scho , fe vce(cluster id)
est store a8

xtreg tb remitpercapita remitpercapitasq inv y yf z aid rents fdi polity dcr inf scho , fe
est store a9


xtreg nonoiltrade remit inv y yf z , fe vce(cluster id)
est store a10

xtreg nonoiltrade remitpercapita inv y yf z , fe vce(cluster id)
est store a11

xtreg nonoiltrade remit inv y yf z aid rents fdi polity dcr inf scho , fe vce(cluster id)
est store a12

xtreg nonoiltrade remitpercapita inv y yf z aid rents fdi polity dcr inf scho , fe vce(cluster id)
est store a13

xi: xtreg nonoiltrade remitpercapita inv remitpcinv y yf z aid rents fdi polity dcr inf scho i.time, fe vce(cluster id)
est store a14

xtreg nonoiltrade remit inv remitinv y yf z aid rents fdi polity dcr inf scho , fe vce(cluster id)
est store a15

xtreg nonoiltrade remit remitsqu inv y yf z aid rents fdi polity dcr inf scho , fe
est store a16

xtreg nonoiltrade remitpercapita inv remitpcinv y yf z aid rents fdi polity dcr inf scho , fe vce(cluster id)
est store a17

xtreg nonoiltrade remitpercapita remitpercapitasq inv y yf z aid rents fdi polity dcr inf scho , fe 
est store a18

esttab a1  a2 a3 a4 a5 a6 a7 a8 a9 a10  a11 a12 a13 a14 a15 a16 a17 a18 using Table_1.1.csv, replace star(* 0.10 ** 0.05 *** 0.01) noconstant scalars(r2 hansenp ar1p ar2p)  nogaps


*figure 2: marginal effect of per capita remittances on non oil trade balance based on model 1.14

xi: xtreg nonoiltrade remitpercapita inv c.remitpercapita#c.inv y yf z aid rents fdi polity dcr inf scho i.time, fe vce(cluster id)

sum inv if e(sample)

margins, dydx(remitpercapita) at(inv=(16 (3) 46)) atmean

marginsplot, yline(0)


*Panel 2SLS results- Table 2

xtivreg2 tb (remit inv remitinv=remit1 remit2 inv1 inv2 remitinv1 remitinv2) y1 yf1 z1 fdi1 aid1 dcr1 polity1 rents1 inf1 scho1, fe robust small
est store iv1

xtivreg2 tb (remit inv remitinv=remit1 remit2 inv1 inv2 remitinv1 remitinv2) remitsq y1 yf1 z1 fdi1 aid1 dcr1 polity1 rents1 inf1 scho1, fe robust small
est store iv2


xtivreg2 tb (remitpercapita inv remitpcinv =l(1/2).remitpercapita inv1 inv2 l(1/2).remitpcinv) y1 yf1 z1 fdi1 aid1 dcr1 polity1 rents1 inf1 scho1, fe robust small
est store iv3

xtivreg2 tb (remitpercapita inv remitpcinv =l(1/2).remitpercapita inv1 inv2 l(1/2).remitpcinv) remitpercapitasq y1 yf1 z1 fdi1 aid1 dcr1 polity1 rents1 inf1 scho1, fe robust small
est store iv4


xtivreg2 nonoiltrade (remit inv remitinv=remit1 remit2 inv1 inv2 remitinv1 remitinv2) y1 yf1 z1 fdi1 aid1 dcr1 polity1 rents1 inf1 scho1, fe robust small
est store iv5

xtivreg2 nonoiltrade (remit inv remitinv=remit1 remit2 inv1 inv2 remitinv1 remitinv2) remitsq y1 yf1 z1 fdi1 aid1 dcr1 polity1 rents1 inf1 scho1, fe robust small
est store iv6

xtivreg2 nonoiltrade (remitpercapita inv remitpcinv =l(1/2).remitpercapita inv1 inv2 l(1/2).remitpcinv) y1 yf1 z1 fdi1 aid1 dcr1 polity1 rents1 inf1 scho1, fe robust small
est store iv7

xtivreg2 nonoiltrade (remitpercapita inv remitpcinv =l(1/2).remitpercapita inv1 inv2 l(1/2).remitpcinv) remitpercapitasq y1 yf1 z1 fdi1 aid1 dcr1 polity1 rents1 inf1 scho1, fe robust small
est store iv8


esttab iv1 iv2 iv3 iv4 iv5 iv6 iv7 iv8 using table_2.csv, replace star(* 0.10 ** 0.05 *** 0.01) noconstant sca("widstat Weak Ident." "sargan Sargan") nogaps






